package com.tlias.jwt.controller;

import com.alibaba.fastjson.JSONObject;
import com.tlias.pojo.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @title: GlobalExceptionHandler
 * @Author gjt
 * @Date: 2020-12-22
 * @Description：
 */
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ResponseBody
    @ExceptionHandler(Exception.class)
    public Object handleException(Exception e) {
        String msg = e.getMessage();
        if (msg == null || msg.equals("")) {
            msg = "服务器出错";
        }
//        JSONObject jsonObject = new JSONObject();
//        jsonObject.put("code", 1000);
//        jsonObject.put("message", msg);
        return Result.error("NOT_LOGIN");
    }
}